package thread.sync.lock;

public class SynchronizedCounter implements Runnable {
	private int v = 0;
	int count = 0;

	@Override
	public void run() {
		synchronized (this) {
			
			increment();
			decrement();
			
			if (v != 0){
				count++;
			}
		}
	}

	public void increment() {
    	for (int i=0; i < 1000000; i++){
    		v++;
    	}
    }

    public void decrement() {
    	for (int i=0; i < 1000000; i++){
    		v--;
    	}
    }
}
